package com.ctshk.rpc.guide.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ctshk.rpc.guide.entity.GroupDistributionGiveGroup;
import com.ctshk.rpc.guide.req.GuideCollarQueryLeisureReq;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 派团送团用户表 Mapper 接口
 * </p>
 *
 * @author 谢诗宏
 * @since 2021-03-15
 */
public interface GroupDistributionGiveGroupMapper extends BaseMapper<GroupDistributionGiveGroup> {

    @Select("select gdgg.give_group_guide_collar_id from t_group_distribution_give_group gdgg LEFT JOIN t_group_distribution gd on gdgg.distribution_id = gd.id where gdgg.is_deleted = 0 and gd.is_deleted = 0 and (DATE_FORMAT(gd.scattered_time,\"%Y-%m-%d\") < DATE_FORMAT(#{req.beginDate},\"%Y-%m-%d\") or DATE_FORMAT(gd.aggregate_time,\"%Y-%m-%d\") > DATE_FORMAT(#{req.endDate},\"%Y-%m-%d\"))")
    List<String> getGroupDistributionIds(@Param("req") GuideCollarQueryLeisureReq req);

}
